export default {
  bind(el, bindings) { //bind()钩子函数
    console.log("指令绑定到元素上的时候");
    //bind有两个参数el为指令绑定的元素
    console.log('el', el); //el为指令绑定的元素
    console.log('bindings', bindings); //bindings为指令的信息,其中value为传入的参数
    console.log('bindings.value', bindings.value);
    //获取所有权限
    const permissions = JSON.parse(localStorage.getItem('permissions'))
    console.log(permissions);
    //需要的权限
    const needPermission = bindings.value
      //是否拥有这个权限
    const hasPermission = permissions.includes(needPermission);
    console.log('bind time');
    //没有这个权限的话就隐藏按钮
    if (!hasPermission) {
      el.style.display = 'none'
      setTimeout(() => {
        console.log('set timeout');
        el.parentNode.removeChild(el)
      }, 0)

    }
  }
}